package group.hhsw.purchase.service.impl;

import group.hhsw.common.model.params.Check;
import group.hhsw.common.model.vo.DetailOrder;
import group.hhsw.feign.clients.ProductClient;
import group.hhsw.feign.clients.UserProductClient;
import group.hhsw.purchase.service.PurchaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("8")
public class CheckSinglePersonAmountLimit  implements PurchaseService {

    @Autowired
    private UserProductClient userProductClient;

    @Autowired
    private ProductClient productClient;

    @Override
    public DetailOrder atomicService(Check check) {
        Long userPurchaseAmount = userProductClient.getUserPurchaseAmount(check.getAccount(), check.getProductId());
        Long singlePersonAmount = productClient.getSinglePersonAmount(check.getProductId());
        DetailOrder order = new DetailOrder();
        order.setUserLimitAmountIsOk(userPurchaseAmount < singlePersonAmount);
        return null;
    }
}
